<template>
  <a-card :bordered="false">
    <div style="padding: 14px 0">
      <div style="display: flex">
        <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('排行榜') }}</div>
        <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
          <a-col :span="24">
            <a-checkbox
              style="line-height: 32px"
              v-model="appletRanking.ivalues"
              @change="parameterChange('appletRanking')"
              >{{ $t('显示') }}</a-checkbox
            >
            <span style="margin-left: 15px; color: orange">{{ $t('（关闭后小程序上将不再显示排行榜相关功能）') }}</span>
          </a-col>
        </a-row>
      </div>
      <div style="display: flex; padding: 10px 0 0 0" v-if="appletRanking.ivalues">
        <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000"></div>
        <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
          <a-col :span="3">
            <a-checkbox
              style="line-height: 32px"
              v-model="appletRankingOfDeposit.ivalues"
              @change="parameterChange('appletRankingOfDeposit')"
              >{{ $t('存票排行') }}</a-checkbox
            >
          </a-col>
          <a-col :span="3">
            <a-checkbox
              style="line-height: 32px"
              v-model="appletRankingOfDepositA.ivalues"
              @change="parameterChange('appletRankingOfDepositA')"
              >{{ $t('存A票排行') }}</a-checkbox
            >
          </a-col>
          <a-col :span="3">
            <a-checkbox
              style="line-height: 32px"
              v-model="appletRankingOfConsume.ivalues"
              @change="parameterChange('appletRankingOfConsume')"
              >{{ $t('消费排行') }}</a-checkbox
            >
          </a-col>
          <a-col :span="3">
            <a-checkbox
              style="line-height: 32px"
              v-model="appletRankingOfRecharge.ivalues"
              @change="parameterChange('appletRankingOfRecharge')"
              >{{ $t('充值排行') }}</a-checkbox
            >
          </a-col>
        </a-row>
      </div>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('自定义充值') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="selfRecharge.ivalues"
            @change="parameterChange('selfRecharge')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（关闭后小程序上购币功能将不再支持自定义充值）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="padding: 14px 0">
      <div style="display: flex;">
        <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('小程序查看流水') }}</div>
        <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
          <a-col :span="24">
            <a-checkbox
              style="line-height: 32px"
              v-model="appletGetMemberFlow.ivalues"
              @change="parameterChange('appletGetMemberFlow')"
              >{{ $t('启用') }}</a-checkbox
            >
            <span style="margin-left: 15px; color: orange">{{
              $t('（关闭后小程序上的相关流水均不显示）')
            }}</span>
          </a-col>
          <a-row>
            <a-col :span="2">
              <a-checkbox
                style="line-height: 32px"
                v-model="appletFlowOrder.ivalues"
                @change="parameterChange('appletFlowOrder')"
                >{{ $t('我的订单') }}</a-checkbox
              >
            </a-col>
            <a-col :span="2">
              <a-checkbox
                style="line-height: 32px"
                v-model="appletFlowCoin.ivalues"
                @change="parameterChange('appletFlowCoin')"
                >{{ $t('代币') }}</a-checkbox
              >
            </a-col>
            <a-col :span="2">
              <a-checkbox
                style="line-height: 32px"
                v-model="appletFlowLottery.ivalues"
                @change="parameterChange('appletFlowLottery')"
                >{{ $t('彩票') }}</a-checkbox
              >
            </a-col>
            <a-col :span="2">
              <a-checkbox
                style="line-height: 32px"
                v-model="appletFlowIntegral.ivalues"
                @change="parameterChange('appletFlowIntegral')"
                >{{ $t('积分') }}</a-checkbox
              >
            </a-col>
            <a-col :span="2">
              <a-checkbox
                style="line-height: 32px"
                v-model="appletFlowLotteryA.ivalues"
                @change="parameterChange('appletFlowLotteryA')"
                >{{ $t('A票') }}</a-checkbox
              >
            </a-col>
            <a-col :span="2">
              <a-checkbox
                style="line-height: 32px"
                v-model="appletFlowCoinA.ivalues"
                @change="parameterChange('appletFlowCoinA')"
                >{{ $t('Z票') }}</a-checkbox
              >
            </a-col>
            <a-col :span="2">
              <a-checkbox
                style="line-height: 32px"
                v-model="appletFlowGrowth.ivalues"
                @change="parameterChange('appletFlowGrowth')"
                >{{ $t('成长值') }}</a-checkbox
              >
            </a-col>
          </a-row>
        </a-row>
      </div>
      <div style="display: flex; padding: 10px 0 0 0" v-if="appletGetMemberFlow.ivalues">
        <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000"></div>
        
      </div>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('小程序充值授权') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="appletAuthRecharge.ivalues"
            @change="parameterChange('appletAuthRecharge')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（开启后小程序上新注册的会员必须要场地授权后才允许充值）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('绑卡身份验证') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="3">
          <a-checkbox
            style="line-height: 32px"
            v-model="bindCardWithPhone.ivalues"
            @change="parameterChange('bindCardWithPhone')"
            >{{ $t('手机验证') }}</a-checkbox
          >
        </a-col>
        <a-col :span="3">
          <a-checkbox
            style="line-height: 32px"
            v-model="bindCardWithPwd.ivalues"
            @change="parameterChange('bindCardWithPwd')"
            >{{ $t('消费密码') }}</a-checkbox
          >
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('小程序会员解绑') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="appletUnbindCard.ivalues"
            @change="parameterChange('appletUnbindCard')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（关闭后小程序上已经绑过卡的会员将不能自助解绑）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('小程序门票分享') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="allowTicketSharing.ivalues"
            @change="parameterChange('allowTicketSharing')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{ $t('（关闭后小程序上门票将不在支持分享）') }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('扫码投币模式') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <j-dict-select-tag
            :placeholder="$t('请选择')"
            style="width: 160px; margin-right: 10px"
            v-model="inputByScan.ivalue"
            dictCode="bis_game.input_by_scan"
          />
          <a-button type="primary" style="margin-left: 20px" @click="parameterChange('inputByScan')" v-has="'BisSysParameterController:edit'">{{
            $t('保存')
          }}</a-button>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('小程序注册赠送') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <span>{{ $t('代币') }}</span>
          <a-input-number
            v-model="presentCoin.ivalue"
            style="width: 130px; margin-right: 10px; margin-left: 3px"
            :precision="0"
            :min="0"
            :max="99999999"
          />
          <span>{{ $t('彩票') }}</span>
          <a-input-number
            v-model="presentLottery.ivalue"
            style="width: 130px; margin-right: 10px; margin-left: 3px"
            :precision="0"
            :min="0"
            :max="99999999"
          />
          <span>{{ $t('积分') }}</span>
          <a-input-number
            v-model="presentIntegral.ivalue"
            style="width: 130px; margin-right: 10px; margin-left: 3px"
            :precision="0"
            :min="0"
            :max="99999999"
          />
          <span>{{ $t('A币') }}</span>
          <a-input-number
            v-model="presentACoin.ivalue"
            style="width: 130px; margin-right: 10px; margin-left: 3px"
            :precision="0"
            :min="0"
            :max="99999999"
          />
          <span>{{ $t('A票') }}</span>
          <a-input-number
            v-model="presentALottery.ivalue"
            style="width: 130px; margin-right: 10px; margin-left: 3px"
            :precision="0"
            :min="0"
            :max="99999999"
          />
          <a-button type="primary" style="margin-left: 20px" @click="presentRuleChange()" v-has="'BisSysParameterController:edit'">{{ $t('保存') }}</a-button>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('库存显示') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="appletStock.ivalues"
            @change="parameterChange('appletStock')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（启用后销售兑换商品将显示库存，库存不足则禁止销售）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('我的推广') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="myPromotion.ivalues"
            @change="parameterChange('myPromotion')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（启用后小程序会员可自主注册为分销员，并查看自己的分销业绩）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('首页钱包') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24" style="display: flex; align-items: center">
          <span style="white-space: nowrap; padding-right: 10px">{{ $t('第一项') }}</span>
          <a-select
            v-model="appletHomeWalletOne.svalue"
            :placeholder="$t('请选择')"
            @change="changeWalletOne"
            style="width: 120px; margin-right: 20px"
          >
            <a-select-option :value="item.type" :key="index" v-for="(item, index) in wallets">
              <span>{{ item.name }}</span>
            </a-select-option>
          </a-select>
          <span style="white-space: nowrap; padding-right: 10px">{{ $t('第二项') }}</span>
          <a-select
            v-model="appletHomeWalletTwo.svalue"
            :placeholder="$t('请选择')"
            @change="changeWalletTwo"
            style="width: 120px; margin-right: 20px"
          >
            <a-select-option :value="item.type" :key="index" v-for="(item, index) in wallets">
              <span>{{ item.name }}</span>
            </a-select-option>
          </a-select>
          <span style="white-space: nowrap; padding-right: 10px">{{ $t('第三项') }}</span>
          <a-select
            v-model="appletHomeWalletThree.svalue"
            :placeholder="$t('请选择')"
            @change="changeWalletThree"
            style="width: 120px; margin-right: 10px"
          >
            <a-select-option :value="item.type" :key="index" v-for="(item, index) in wallets">
              <span>{{ item.name }}</span>
            </a-select-option>
          </a-select>
          <span style="color: orange">{{ $t('（用于小程序首页钱包功能设置，设置哪种则展示哪种钱包）') }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('更改手机号') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="changePhone.ivalues"
            @change="parameterChange('changePhone')"
            >{{ $t('允许') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（关闭后小程序将不能自主更改会员手机号）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    
    <div style="display: flex; padding: 14px 0" v-if="info.typeCode_dictText != 6">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('邮箱注册') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="appletEmailReg.ivalues"
            @change="parameterChange('appletEmailReg')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（启用后小程序支持使用邮箱认证注册）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0" v-if="info.typeCode_dictText == 6">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('手机号注册') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="appPhoneReg.ivalues"
            @change="parameterChange('appPhoneReg')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（启用后会员APP支持使用手机号认证注册）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0" v-if="info.typeCode_dictText == 6">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('游客访问') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox
            style="line-height: 32px"
            v-model="appVisitor.ivalues"
            @change="parameterChange('appVisitor')"
            >{{ $t('启用') }}</a-checkbox
          >
          <span style="margin-left: 15px; color: orange">{{
            $t('（启用后会员APP在不注册的情况下即可浏览访问）')
          }}</span>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('业务控制') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <span style="line-height: 32px; color: orange">{{
            $t('根据需要可自定义启用或关闭小程序上的功能或调整各功能的显示顺序')
          }}</span>
        </a-col>
        <a-col :span="24" style="padding-top: 0">
          <a-table
            bordered
            size="small"
            class="table-padlr0"
            :columns="columns"
            :data-source="dataSource"
            :pagination="false"
            style="width: 600px"
          >
            <template slot="stateSlot" slot-scope="text, record">
              <a-checkbox :checked="text == 1 ? true : false" @change="onChange($event, record)" v-has="'BisSysParameterController:edit'"/>
            </template>
            <template v-for="col in ['sort']" :slot="col" slot-scope="text, record">
              <div :key="col" style="display: flex; justify-content: center">
                <div>
                  <a-input
                    v-if="record.editable"
                    style="margin: -5px 0; padding: 0; width: 50px"
                    :value="text"
                    @change="(e) => handleChange(e.target.value, record.id, col)"
                    :maxLength="3"
                  />
                  <template v-else>{{ text }}</template>
                </div>
                <div class="editable-row-operations">
                  <span v-if="record.editable">
                    <a @click="() => save2(record.id)"><a-icon type="save" /></a>
                  </span>
                  <span v-else>
                    <a :disabled="editingKey !== ''" @click="() => edit(record.id)"><a-icon type="edit" /></a>
                  </span>
                </div>
              </div>
            </template>
            <template slot="functionName" slot-scope="text, record">
              <div style="display: flex; justify-content: center">
                <div>
                  <a-input
                    v-if="record.feditable"
                    style="margin: -5px 0; padding: 0; width: 160px"
                    v-model="record.functionName"
                  />
                  <template v-else>{{ record.functionName }}</template>
                </div>
                <div class="editable-row-operations">
                  <span v-if="record.feditable">
                    <a @click="() => save2(record.id)"><a-icon type="save" /></a>
                  </span>
                  <span v-else>
                    <a :disabled="feditingKey !== ''" @click="() => fedit(record.id)"><a-icon type="edit" /></a>
                  </span>
                </div>
              </div>
            </template>
            <template slot="imgSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
              <a-popover v-else trigger="hover">
                <template slot="content">
                  <img :src="getImgView(text)" width="240px" />
                </template>
                <img
                  :src="getImgView(text)"
                  height="25px"
                  alt=""
                  style="max-width: 80px; font-size: 12px; font-style: italic"
                />
              </a-popover>
            </template>
            <template slot="action" slot-scope="text, record">
              <a @click="handleEdit(record)" v-has="'BisSysParameterController:edit'">{{ $t('编辑') }}</a>
            </template>
          </a-table>
        </a-col>
      </a-row>
    </div>
    <div style="display: flex; padding: 14px 0">
      <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000">{{ $t('会员签到') }}</div>
      <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
        <a-col :span="24">
          <a-checkbox style="line-height: 32px" v-model="signinObj.states">{{ $t('启用') }}</a-checkbox>
          <span style="margin-left: 15px; color: orange">{{
            $t('（每15天为一个签到周期，需分别设置日常签到奖励和连续签到奖励）')
          }}</span>
        </a-col>
        <a-col :span="24" style="display: flex">
          <div style="line-height: 32px">{{ $t('日常签到奖励') }}：</div>
          <div>
            <a-select
              show-search
              :placeholder="$t('请选择优惠券')"
              style="width: 200px"
              :filter-option="false"
              @search="getCoupons"
              v-model="signinObj.couponId"
            >
              <a-select-option :value="item.id" :key="index" v-for="(item, index) in coupons">
                <span>{{ item.name }}</span>
              </a-select-option>
            </a-select>
          </div>
        </a-col>
        <a-col :span="24" style="display: flex">
          <div style="line-height: 32px">{{ $t('连续签到奖励') }}：</div>
          <div>
            <div v-for="(sign, i) in signinList" :key="i" style="margin-bottom: 10px">
              <a-input
                v-model="sign.day"
                style="width: 200px"
                :disabled="sign.disabled"
                oninput="value=value.replace(/\D/g,''); if(parseInt(value) > 15)value = 15"
              ></a-input>
              <span style="padding: 0 4px">{{ $t('天赠送') }}</span>
              <a-select
                show-search
                :placeholder="$t('请选择优惠券')"
                style="width: 200px"
                :filter-option="false"
                @search="getCoupons"
                v-model="sign.couponId"
                :disabled="sign.disabled"
              >
                <a-select-option :value="item.id" :key="index" v-for="(item, index) in coupons">
                  <span>{{ item.name }}</span>
                </a-select-option>
              </a-select>
              <span>
                <a-icon
                  v-if="sign.disabled"
                  @click="editSignin(sign)"
                  type="edit"
                  style="color: #1890ff; cursor: pointer; margin-left: 5px"
                />
                <a-icon
                  v-else
                  type="check"
                  @click="saveSignin(sign, i)"
                  style="color: #1890ff; cursor: pointer; margin-left: 5px"
                />
              </span>
              <a-icon type="close" @click="delSignin(i)" style="color: #1890ff; cursor: pointer; margin-left: 5px" />
              <a-icon
                type="plus"
                v-if="i == signinList.length - 1"
                @click="addSignin"
                style="color: #1890ff; cursor: pointer; margin-left: 5px"
              />
            </div>
          </div>
        </a-col>
        <a-col :span="24">
          <a-button type="primary" @click="saveSigninRule" v-has="'BisSysParameterController:edit'">{{ $t('保存') }}</a-button>
        </a-col>
      </a-row>
    </div>
    <edit-business-modal ref="modalForm" @ok="modalFormOk"></edit-business-modal>
  </a-card>
</template>

<script>
import { getAction, httpAction, postAction, putAction } from '@/api/manage'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { initDictOptions } from '@/components/dict/JDictSelectUtil'
import EditBusinessModal from './modules/EditBusinessModal'
import axios from 'axios'

export default {
  name: 'OperationSetting',
  components: {
    EditBusinessModal,
  },
  mixins: [JeecgListMixin, mixinDevice],
  data() {
    return {
      description: '运营设置',
      // 表头
      columns: [
        {
          title: this.$t('排序序号'),
          align: 'center',
          dataIndex: 'sort',
          scopedSlots: { customRender: 'sort' },
        },
        {
          title: this.$t('名称'),
          align: 'center',
          dataIndex: 'functionName',
          scopedSlots: { customRender: 'functionName' },
        },
        {
          title: this.$t('图片'),
          align: 'center',
          dataIndex: 'iconUrl',
          scopedSlots: { customRender: 'imgSlot' },
        },
        {
          title: this.$t('状态'),
          align: 'center',
          dataIndex: 'state',
          scopedSlots: { customRender: 'stateSlot' },
        },
        {
          title: this.$t('操作'),
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        },
      ],
      editingKey: '',
      feditingKey: '',
      isorter: {
        column: 'sort',
        order: 'asc',
      },
      ipagination: {
        pageSize: 100,
      },
      info: {},
      appletGetMemberFlow: {
        name: 'appletGetMemberFlow',
        ivalues: true,
        ivalue: 1,
        comment: '小程序查看流水',
      },
      appletFlowOrder: {
        name: 'appletFlowOrder',
        ivalues: true,
        ivalue: 1,
        comment: '小程序查看流水-我的订单',
      },
      appletFlowCoin: {
        name: 'appletFlowCoin',
        ivalues: true,
        ivalue: 1,
        comment: '小程序查看流水-代币',
      },
      appletFlowLottery: {
        name: 'appletFlowLottery',
        ivalues: true,
        ivalue: 1,
        comment: '小程序查看流水-彩票',
      },
      appletFlowIntegral: {
        name: 'appletFlowIntegral',
        ivalues: true,
        ivalue: 1,
        comment: '小程序查看流水-积分',
      },
      appletFlowLotteryA: {
        name: 'appletFlowLotteryA',
        ivalues: true,
        ivalue: 1,
        comment: '小程序查看流水-A票',
      },
      appletFlowCoinA: {
        name: 'appletFlowCoinA',
        ivalues: true,
        ivalue: 1,
        comment: '小程序查看流水-Z票',
      },
      appletFlowGrowth: {
        name: 'appletFlowGrowth',
        ivalues: true,
        ivalue: 1,
        comment: '小程序查看流水-成长值',
      },
      selfRecharge: {
        name: 'selfRecharge',
        ivalues: true,
        ivalue: 1,
        comment: '自定义充值',
      },
      appletRanking: {
        name: 'appletRanking',
        ivalues: true,
        ivalue: 1,
        comment: '小程序排行榜',
      },
      appletRankingOfDeposit: {
        name: 'appletRankingOfDeposit',
        ivalues: true,
        ivalue: 1,
        comment: '小程序排行榜-存票排行',
      },
      appletRankingOfDepositA: {
        name: 'appletRankingOfDepositA',
        ivalues: false,
        ivalue: 0,
        comment: '小程序排行榜-存A票排行',
      },
      appletRankingOfConsume: {
        name: 'appletRankingOfConsume',
        ivalues: true,
        ivalue: 1,
        comment: '小程序排行榜-消费排行',
      },
      appletRankingOfRecharge: {
        name: 'appletRankingOfRecharge',
        ivalues: true,
        ivalue: 1,
        comment: '小程序排行榜-充值排行',
      },
      appletAuthRecharge: {
        name: 'appletAuthRecharge',
        ivalues: false,
        ivalue: 0,
        comment: '小程序充值授权',
      },
      bindCardWithPhone: {
        name: 'bindCardWithPhone',
        ivalues: true,
        ivalue: 1,
        comment: '绑卡身份验证-手机验证',
      },
      bindCardWithPwd: {
        name: 'bindCardWithPwd',
        ivalues: true,
        ivalue: 1,
        comment: '绑卡身份验证-消费密码',
      },
      appletUnbindCard: {
        name: 'appletUnbindCard',
        ivalues: true,
        ivalue: 1,
        comment: '小程序会员解绑',
      },
      inputByScan: {
        name: 'inputByScan',
        ivalue: 0,
        comment: '扫码投币（0-自动，1-人工）',
      },
      presentCoin: {
        name: 'presentCoin',
        ivalue: 0,
        comment: '小程序注册赠代币',
      },
      presentLottery: {
        name: 'presentLottery',
        ivalue: 0,
        comment: '小程序注册赠彩票',
      },
      presentIntegral: {
        name: 'presentIntegral',
        ivalue: 0,
        comment: '小程序注册赠积分',
      },
      presentACoin: {
        name: 'presentACoin',
        ivalue: 0,
        comment: '小程序注册赠A币',
      },
      presentALottery: {
        name: 'presentALottery',
        ivalue: 0,
        comment: '小程序注册赠A票',
      },
      allowTicketSharing: {
        name: 'allowTicketSharing',
        ivalues: true,
        ivalue: 1,
        comment: '小程序门票分享',
      },
      appletStock: {
        name: 'appletStock',
        ivalues: false,
        ivalue: 0,
        comment: '库存显示',
      },
      myPromotion: {
        name: 'myPromotion',
        ivalues: false,
        ivalue: 0,
        comment: '小程序我的推广',
      },
      appletEmailReg: {
        name: 'appletEmailReg',
        ivalues: false,
        ivalue: 0,
        comment: '小程序邮箱注册',
      },
      appPhoneReg: {
        name: 'appPhoneReg',
        ivalues: false,
        ivalue: 0,
        comment: 'APP手机号注册',
      },
      appVisitor: {
        name: 'appVisitor',
        ivalues: false,
        ivalue: 0,
        comment: 'APP游客访问',
      },
      changePhone: {
        name: 'changePhone',
        ivalues: true,
        ivalue: 1,
        comment: '小程序更改手机号',
      },
      url: {
        list: '/applet/bisAppletFunctionSet/list',
        edit: '/applet/bisAppletFunctionSet/edit',
      },
      signinObj: {
        states: false,
      },
      signinList: [],
      coupons: [],
      wallets: [
        {
          type: '1',
          name: this.$t('代币'),
        },
        {
          type: '2',
          name: this.$t('彩票'),
        },
        {
          type: '3',
          name: this.$t('A币'),
        },
        {
          type: '4',
          name: this.$t('A票'),
        },
        {
          type: '5',
          name: this.$t('积分'),
        },
        {
          type: '6',
          name: this.$t('成长值'),
        },
        {
          type: '7',
          name: this.$t('优惠券'),
        },
        {
          type: '8',
          name: this.$t('门票'),
        },
      ],
      appletHomeWalletOne: {
        name: 'appletHomeWalletOne',
        ivalue: 1,
        svalue: '1',
        comment: '小程序首页钱包-第一项',
      },
      appletHomeWalletTwo: {
        name: 'appletHomeWalletTwo',
        ivalue: 1,
        svalue: '2',
        comment: '小程序首页钱包-第二项',
      },
      appletHomeWalletThree: {
        name: 'appletHomeWalletThree',
        ivalue: 1,
        svalue: '7',
        comment: '小程序首页钱包-第三项',
      },
    }
  },
  created() {
    this.getParameter('appletGetMemberFlow')
    this.getParameter('appletFlowOrder')
    this.getParameter('appletFlowCoin')
    this.getParameter('appletFlowLottery')
    this.getParameter('appletFlowIntegral')
    this.getParameter('appletFlowLotteryA')
    this.getParameter('appletFlowCoinA')
    this.getParameter('appletFlowGrowth')
    this.getParameter('selfRecharge')
    this.getParameter('appletRanking')
    this.getParameter('appletRankingOfDeposit')
    this.getParameter('appletRankingOfDepositA')
    this.getParameter('appletRankingOfConsume')
    this.getParameter('appletRankingOfRecharge')
    this.getParameter('appletAuthRecharge')
    this.getParameter('bindCardWithPhone')
    this.getParameter('bindCardWithPwd')
    this.getParameter('appletUnbindCard')
    this.getParameter('inputByScan')
    this.getParameter('allowTicketSharing')
    this.getParameter('appletStock')
    this.getParameter('myPromotion')
    this.getParameter('appletEmailReg')
    this.getParameter('appPhoneReg')
    this.getParameter('appVisitor')
    this.getParameter('changePhone')
    this.getPresentRule()
    this.getSignins()
    this.getWallets()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  mounted() {
    getAction('/shop/bisShop/list', {}).then(async (res) => {
      if (res.success) {
        this.info = res.result.records[0]
      } else {
        this.$message.warning(res.message)
      }
    })
    
  },
  methods: {
    modalFormOk() {
      this.loadData(1)
    },
    presentRuleChange() {
      let that = this
      let httpurl = '/bis/bisSysParameter/saveBatch'
      let method = 'post'
      let query = []
      query.push(that.presentCoin)
      query.push(that.presentLottery)
      query.push(that.presentIntegral)
      query.push(that.presentACoin)
      query.push(that.presentALottery)
      httpAction(httpurl, query, method).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.getPresentRule()
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    getPresentRule() {
      axios
        .all([
          this.queryByName('presentCoin'),
          this.queryByName('presentLottery'),
          this.queryByName('presentIntegral'),
          this.queryByName('presentACoin'),
          this.queryByName('presentALottery'),
        ])
        .then(
          axios.spread((r1, r2, r3, r4, r5) => {
            if (r1.success) {
              this.presentCoin.id = r1.result.id
              this.presentCoin.ivalue = r1.result.ivalue
            }
            if (r2.success) {
              this.presentLottery.id = r2.result.id
              this.presentLottery.ivalue = r2.result.ivalue
            }
            if (r3.success) {
              this.presentIntegral.id = r3.result.id
              this.presentIntegral.ivalue = r3.result.ivalue
            }
            if (r4.success) {
              this.presentACoin.id = r4.result.id
              this.presentACoin.ivalue = r4.result.ivalue
            }
            if (r5.success) {
              this.presentALottery.id = r5.result.id
              this.presentALottery.ivalue = r5.result.ivalue
            }
          })
        )
    },
    queryByName(name) {
      return getAction('/bis/bisSysParameter/queryByName', { name: name })
    },
    initDictConfig() {},
    save(record, state, type) {
      if (state) {
        record.state = 'Y'
        if (record.consumeAmount == null || record.obtainIntegral == null) {
          this.$message.warning(this.$t('值不能为空'))
          return
        }
        if (record.consumeAmount < 0 || record.obtainIntegral < 0) {
          this.$message.warning(this.$t('值不能小于0'))
          return
        }
        if (record.consumeAmount == 0 || record.obtainIntegral == 0) {
          this.$message.warning(this.$t('值不能为0'))
          return
        }
        if (type != 3 && (record.consumeAmount % 1 != 0 || record.obtainIntegral % 1 != 0)) {
          this.$message.warning(this.$t('值不能为小数'))
          return
        }
      } else {
        record.state = 'N'
      }
      record.type = type
      let url = ''
      let method = ''
      if (record.id) {
        url = this.url.edit
        method = 'put'
      } else {
        url = this.url.add
        method = 'post'
      }
      httpAction(url, record, method).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.getRule()
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    getParameter(name) {
      getAction('/bis/bisSysParameter/list', { name: name }).then((res) => {
        if (res.success) {
          if (res.result.records.length > 0) {
            if (name === 'appletGetMemberFlow') {
              this.appletGetMemberFlow = res.result.records[0]
              this.appletGetMemberFlow.ivalues = this.appletGetMemberFlow.ivalue ? true : false
            }
            if (name === 'appletFlowOrder') {
              this.appletFlowOrder = res.result.records[0]
              this.appletFlowOrder.ivalues = this.appletFlowOrder.ivalue ? true : false
            }
            if (name === 'appletFlowCoin') {
              this.appletFlowCoin = res.result.records[0]
              this.appletFlowCoin.ivalues = this.appletFlowCoin.ivalue ? true : false
            }
            if (name === 'appletFlowLottery') {
              this.appletFlowLottery = res.result.records[0]
              this.appletFlowLottery.ivalues = this.appletFlowLottery.ivalue ? true : false
            }
            if (name === 'appletFlowIntegral') {
              this.appletFlowIntegral = res.result.records[0]
              this.appletFlowIntegral.ivalues = this.appletFlowIntegral.ivalue ? true : false
            }
            if (name === 'appletFlowLotteryA') {
              this.appletFlowLotteryA = res.result.records[0]
              this.appletFlowLotteryA.ivalues = this.appletFlowLotteryA.ivalue ? true : false
            }
            if (name === 'appletFlowCoinA') {
              this.appletFlowCoinA = res.result.records[0]
              this.appletFlowCoinA.ivalues = this.appletFlowCoinA.ivalue ? true : false
            }
            if (name === 'appletFlowGrowth') {
              this.appletFlowGrowth = res.result.records[0]
              this.appletFlowGrowth.ivalues = this.appletFlowGrowth.ivalue ? true : false
            }
            if (name === 'selfRecharge') {
              this.selfRecharge = res.result.records[0]
              this.selfRecharge.ivalues = this.selfRecharge.ivalue ? true : false
            }
            if (name === 'appletRanking') {
              this.appletRanking = res.result.records[0]
              this.appletRanking.ivalues = this.appletRanking.ivalue ? true : false
            }
            if (name === 'appletRankingOfDeposit') {
              this.appletRankingOfDeposit = res.result.records[0]
              this.appletRankingOfDeposit.ivalues = this.appletRankingOfDeposit.ivalue ? true : false
            }
            if (name === 'appletRankingOfDepositA') {
              this.appletRankingOfDepositA = res.result.records[0]
              this.appletRankingOfDepositA.ivalues = this.appletRankingOfDepositA.ivalue ? true : false
            }
            if (name === 'appletRankingOfConsume') {
              this.appletRankingOfConsume = res.result.records[0]
              this.appletRankingOfConsume.ivalues = this.appletRankingOfConsume.ivalue ? true : false
            }
            if (name === 'appletRankingOfRecharge') {
              this.appletRankingOfRecharge = res.result.records[0]
              this.appletRankingOfRecharge.ivalues = this.appletRankingOfRecharge.ivalue ? true : false
            }

            if (name === 'appletAuthRecharge') {
              this.appletAuthRecharge = res.result.records[0]
              this.appletAuthRecharge.ivalues = this.appletAuthRecharge.ivalue ? true : false
            }
            if (name === 'bindCardWithPhone') {
              this.bindCardWithPhone = res.result.records[0]
              this.bindCardWithPhone.ivalues = this.bindCardWithPhone.ivalue ? true : false
            }
            if (name === 'bindCardWithPwd') {
              this.bindCardWithPwd = res.result.records[0]
              this.bindCardWithPwd.ivalues = this.bindCardWithPwd.ivalue ? true : false
            }
            if (name === 'appletUnbindCard') {
              this.appletUnbindCard = res.result.records[0]
              this.appletUnbindCard.ivalues = this.appletUnbindCard.ivalue ? true : false
            }
            if (name === 'allowTicketSharing') {
              this.allowTicketSharing = res.result.records[0]
              this.allowTicketSharing.ivalues = this.allowTicketSharing.ivalue ? true : false
            }
            if (name === 'appletStock') {
              this.appletStock = res.result.records[0]
              this.appletStock.ivalues = this.appletStock.ivalue ? true : false
            }
            if (name === 'myPromotion') {
              this.myPromotion = res.result.records[0]
              this.myPromotion.ivalues = this.myPromotion.ivalue ? true : false
            }
            if (name === 'appletEmailReg') {
              this.appletEmailReg = res.result.records[0]
              this.appletEmailReg.ivalues = this.appletEmailReg.ivalue ? true : false
            }
            if (name === 'appPhoneReg') {
              this.appPhoneReg = res.result.records[0]
              this.appPhoneReg.ivalues = this.appPhoneReg.ivalue ? true : false
            }
            if (name === 'appVisitor') {
              this.appVisitor = res.result.records[0]
              this.appVisitor.ivalues = this.appVisitor.ivalue ? true : false
            }
            if (name === 'changePhone') {
              this.changePhone = res.result.records[0]
              this.changePhone.ivalues = this.changePhone.ivalue ? true : false
            }
            if (name === 'inputByScan') {
              this.inputByScan = res.result.records[0]
            }
          } else {
            if (name === 'appletGetMemberFlow') {
              this.appletGetMemberFlow.ivalues = true
            }
            if (name === 'appletFlowOrder') {
              this.appletFlowOrder.ivalues = true
            }
            if (name === 'appletFlowCoin') {
              this.appletFlowCoin.ivalues = true
            }
            if (name === 'appletFlowLottery') {
              this.appletFlowLottery.ivalues = true
            }
            if (name === 'appletFlowIntegral') {
              this.appletFlowIntegral.ivalues = true
            }
            if (name === 'appletFlowLotteryA') {
              this.appletFlowLotteryA.ivalues = true
            }
            if (name === 'appletFlowCoinA') {
              this.appletFlowCoinA.ivalues = true
            }
            if (name === 'appletFlowGrowth') {
              this.appletFlowGrowth.ivalues = true
            }
            if (name === 'selfRecharge') {
              this.selfRecharge.ivalues = true
            }
            if (name === 'appletRanking') {
              this.appletRanking.ivalues = true
            }
            if (name === 'appletRankingOfDeposit') {
              this.appletRankingOfDeposit.ivalues = true
            }
            if (name === 'appletRankingOfDepositA') {
              this.appletRankingOfDepositA.ivalues = false
            }
            if (name === 'appletRankingOfConsume') {
              this.appletRankingOfConsume.ivalues = true
            }
            if (name === 'appletRankingOfRecharge') {
              this.appletRankingOfRecharge.ivalues = true
            }
            if (name === 'appletAuthRecharge') {
              this.appletAuthRecharge.ivalues = false
            }
            if (name === 'bindCardWithPhone') {
              this.bindCardWithPhone.ivalues = true
            }
            if (name === 'bindCardWithPwd') {
              this.bindCardWithPwd.ivalues = true
            }
            if (name === 'appletUnbindCard') {
              this.appletUnbindCard.ivalues = true
            }
            if (name === 'inputByScan') {
              this.inputByScan.ivalue = 0
            }
            if (name === 'allowTicketSharing') {
              this.allowTicketSharing.ivalues = true
            }
            if (name === 'appletEmailReg') {
              this.appletEmailReg.ivalues = false
            }
            if (name === 'appPhoneReg') {
              this.appPhoneReg.ivalues = false
            }
            if (name === 'appVisitor') {
              this.appVisitor.ivalues = false
            }
            if (name === 'changePhone') {
              this.changePhone.ivalues = true
            }
            if (name === 'appletStock') {
              this.appletStock.ivalues = false
            }
            if (name === 'myPromotion') {
              this.myPromotion.ivalues = false
            }
          }
        }
      })
    },
    parameterChange(name) {
      let that = this,
        querydata = {}
      let url = '',
        method = ''
      if (
        (name === 'appletGetMemberFlow' && that.appletGetMemberFlow.id) ||
        (name === 'appletFlowOrder' && that.appletFlowOrder.id) ||
        (name === 'appletFlowCoin' && that.appletFlowCoin.id) ||
        (name === 'appletFlowLottery' && that.appletFlowLottery.id) ||
        (name === 'appletFlowIntegral' && that.appletFlowIntegral.id) ||
        (name === 'appletFlowLotteryA' && that.appletFlowLotteryA.id) ||
        (name === 'appletFlowCoinA' && that.appletFlowCoinA.id) ||
        (name === 'appletFlowGrowth' && that.appletFlowGrowth.id) ||
        (name === 'selfRecharge' && that.selfRecharge.id) ||
        (name === 'appletRanking' && that.appletRanking.id) ||
        (name === 'appletRankingOfDeposit' && that.appletRankingOfDeposit.id) ||
        (name === 'appletRankingOfDepositA' && that.appletRankingOfDepositA.id) ||
        (name === 'appletRankingOfConsume' && that.appletRankingOfConsume.id) ||
        (name === 'appletRankingOfRecharge' && that.appletRankingOfRecharge.id) ||
        (name === 'appletAuthRecharge' && that.appletAuthRecharge.id) ||
        (name === 'bindCardWithPhone' && that.bindCardWithPhone.id) ||
        (name === 'bindCardWithPwd' && that.bindCardWithPwd.id) ||
        (name === 'appletUnbindCard' && that.appletUnbindCard.id) ||
        (name === 'allowTicketSharing' && that.allowTicketSharing.id) ||
        (name === 'appletStock' && that.appletStock.id) ||
        (name === 'myPromotion' && that.myPromotion.id) ||
        (name === 'appletEmailReg' && that.appletEmailReg.id) ||
        (name === 'appPhoneReg' && that.appPhoneReg.id) ||
        (name === 'appVisitor' && that.appVisitor.id) ||
        (name === 'changePhone' && that.changePhone.id) ||
        (name === 'inputByScan' && that.inputByScan.id)
      ) {
        url = '/bis/bisSysParameter/edit'
        method = 'put'
      } else {
        url = '/bis/bisSysParameter/add'
        method = 'post'
      }
      if (name === 'appletGetMemberFlow') {
        if (that.appletGetMemberFlow.ivalues === true) {
          that.appletGetMemberFlow.ivalue = 1
        } else {
          that.appletGetMemberFlow.ivalue = 0
        }
        querydata = Object.assign({}, that.appletGetMemberFlow)
      }
      if (name === 'appletFlowOrder') {
        if (that.appletFlowOrder.ivalues === true) {
          that.appletFlowOrder.ivalue = 1
        } else {
          that.appletFlowOrder.ivalue = 0
        }
        querydata = Object.assign({}, that.appletFlowOrder)
      }
      if (name === 'appletFlowCoin') {
        if (that.appletFlowCoin.ivalues === true) {
          that.appletFlowCoin.ivalue = 1
        } else {
          that.appletFlowCoin.ivalue = 0
        }
        querydata = Object.assign({}, that.appletFlowCoin)
      }
      if (name === 'appletFlowLottery') {
        if (that.appletFlowLottery.ivalues === true) {
          that.appletFlowLottery.ivalue = 1
        } else {
          that.appletFlowLottery.ivalue = 0
        }
        querydata = Object.assign({}, that.appletFlowLottery)
      }
      if (name === 'appletFlowIntegral') {
        if (that.appletFlowIntegral.ivalues === true) {
          that.appletFlowIntegral.ivalue = 1
        } else {
          that.appletFlowIntegral.ivalue = 0
        }
        querydata = Object.assign({}, that.appletFlowIntegral)
      }
      if (name === 'appletFlowCoinA') {
        if (that.appletFlowCoinA.ivalues === true) {
          that.appletFlowCoinA.ivalue = 1
        } else {
          that.appletFlowCoinA.ivalue = 0
        }
        querydata = Object.assign({}, that.appletFlowCoinA)
      }
      if (name === 'appletFlowLotteryA') {
        if (that.appletFlowLotteryA.ivalues === true) {
          that.appletFlowLotteryA.ivalue = 1
        } else {
          that.appletFlowLotteryA.ivalue = 0
        }
        querydata = Object.assign({}, that.appletFlowLotteryA)
      }
      if (name === 'appletFlowGrowth') {
        if (that.appletFlowGrowth.ivalues === true) {
          that.appletFlowGrowth.ivalue = 1
        } else {
          that.appletFlowGrowth.ivalue = 0
        }
        querydata = Object.assign({}, that.appletFlowGrowth)
      }
      if (name === 'selfRecharge') {
        if (that.selfRecharge.ivalues === true) {
          that.selfRecharge.ivalue = 1
        } else {
          that.selfRecharge.ivalue = 0
        }
        querydata = Object.assign({}, that.selfRecharge)
      }
      if (name === 'appletRanking') {
        if (that.appletRanking.ivalues === true) {
          that.appletRanking.ivalue = 1
        } else {
          that.appletRanking.ivalue = 0
        }
        querydata = Object.assign({}, that.appletRanking)
      }
      if (
        name === 'appletRankingOfDeposit' ||
        name === 'appletRankingOfDepositA' ||
        name === 'appletRankingOfConsume' ||
        name === 'appletRankingOfRecharge'
      ) {
        if (
          !that.appletRankingOfDeposit.ivalues &&
          !that.appletRankingOfConsume.ivalues &&
          !that.appletRankingOfRecharge.ivalues &&
          !that.appletRankingOfDepositA.ivalues
        ) {
          that.$message.warning('请至少开启一种排行或关闭排行榜显示')
          that.getParameter(name)
          return
        }
      }
      if (name === 'appletRankingOfDeposit') {
        if (that.appletRankingOfDeposit.ivalues === true) {
          that.appletRankingOfDeposit.ivalue = 1
        } else {
          that.appletRankingOfDeposit.ivalue = 0
        }
        querydata = Object.assign({}, that.appletRankingOfDeposit)
      }
      if (name === 'appletRankingOfDepositA') {
        if (that.appletRankingOfDepositA.ivalues === true) {
          that.appletRankingOfDepositA.ivalue = 1
        } else {
          that.appletRankingOfDepositA.ivalue = 0
        }
        querydata = Object.assign({}, that.appletRankingOfDepositA)
      }
      if (name === 'appletRankingOfConsume') {
        if (that.appletRankingOfConsume.ivalues === true) {
          that.appletRankingOfConsume.ivalue = 1
        } else {
          that.appletRankingOfConsume.ivalue = 0
        }
        querydata = Object.assign({}, that.appletRankingOfConsume)
      }
      if (name === 'appletRankingOfRecharge') {
        if (that.appletRankingOfRecharge.ivalues === true) {
          that.appletRankingOfRecharge.ivalue = 1
        } else {
          that.appletRankingOfRecharge.ivalue = 0
        }
        querydata = Object.assign({}, that.appletRankingOfRecharge)
      }
      if (name === 'appletAuthRecharge') {
        if (that.appletAuthRecharge.ivalues === true) {
          that.appletAuthRecharge.ivalue = 1
        } else {
          that.appletAuthRecharge.ivalue = 0
        }
        querydata = Object.assign({}, that.appletAuthRecharge)
      }
      if (name === 'bindCardWithPhone') {
        if (that.bindCardWithPhone.ivalues === true) {
          that.bindCardWithPhone.ivalue = 1
        } else {
          that.bindCardWithPhone.ivalue = 0
        }
        querydata = Object.assign({}, that.bindCardWithPhone)
      }
      if (name === 'bindCardWithPwd') {
        if (that.bindCardWithPwd.ivalues === true) {
          that.bindCardWithPwd.ivalue = 1
        } else {
          that.bindCardWithPwd.ivalue = 0
        }
        querydata = Object.assign({}, that.bindCardWithPwd)
      }
      if (name === 'appletUnbindCard') {
        if (that.appletUnbindCard.ivalues === true) {
          that.appletUnbindCard.ivalue = 1
        } else {
          that.appletUnbindCard.ivalue = 0
        }
        querydata = Object.assign({}, that.appletUnbindCard)
      }
      if (name === 'inputByScan') {
        if (that.inputByScan.ivalue == null || that.inputByScan.ivalue === "") {
          that.$message.warning('请选择扫码投币模式')
          return
        }
        querydata = Object.assign({}, that.inputByScan)
      }
      if (name === 'allowTicketSharing') {
        if (that.allowTicketSharing.ivalues === true) {
          that.allowTicketSharing.ivalue = 1
        } else {
          that.allowTicketSharing.ivalue = 0
        }
        querydata = Object.assign({}, that.allowTicketSharing)
      }
      if (name === 'appletStock') {
        if (that.appletStock.ivalues === true) {
          that.appletStock.ivalue = 1
        } else {
          that.appletStock.ivalue = 0
        }
        querydata = Object.assign({}, that.appletStock)
      }
      if (name === 'myPromotion') {
        if (that.myPromotion.ivalues === true) {
          that.myPromotion.ivalue = 1
        } else {
          that.myPromotion.ivalue = 0
        }
        querydata = Object.assign({}, that.myPromotion)
      }
      if (name === 'appletEmailReg') {
        if (that.appletEmailReg.ivalues === true) {
          that.appletEmailReg.ivalue = 1
        } else {
          that.appletEmailReg.ivalue = 0
        }
        querydata = Object.assign({}, that.appletEmailReg)
      }
      if (name === 'appPhoneReg') {
        if (that.appPhoneReg.ivalues === true) {
          that.appPhoneReg.ivalue = 1
        } else {
          that.appPhoneReg.ivalue = 0
        }
        querydata = Object.assign({}, that.appPhoneReg)
      }
      if (name === 'appVisitor') {
        if (that.appVisitor.ivalues === true) {
          that.appVisitor.ivalue = 1
        } else {
          that.appVisitor.ivalue = 0
        }
        querydata = Object.assign({}, that.appVisitor)
      }
      if (name === 'changePhone') {
        if (that.changePhone.ivalues === true) {
          that.changePhone.ivalue = 1
        } else {
          that.changePhone.ivalue = 0
        }
        querydata = Object.assign({}, that.changePhone)
      }
      httpAction(url, querydata, method).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.getParameter('appletGetMemberFlow')
          that.getParameter('appletFlowOrder')
          that.getParameter('appletFlowCoin')
          that.getParameter('appletFlowLottery')
          that.getParameter('appletFlowIntegral')
          that.getParameter('appletFlowLotteryA')
          that.getParameter('appletFlowCoinA')
          that.getParameter('appletFlowGrowth')
          that.getParameter('selfRecharge')
          that.getParameter('appletRanking')
          that.getParameter('appletRankingOfDeposit')
          that.getParameter('appletRankingOfDepositA')
          that.getParameter('appletRankingOfConsume')
          that.getParameter('appletRankingOfRecharge')
          that.getParameter('appletAuthRecharge')
          that.getParameter('bindCardWithPhone')
          that.getParameter('bindCardWithPwd')
          that.getParameter('appletUnbindCard')
          that.getParameter('inputByScan')
          that.getParameter('allowTicketSharing')
          that.getParameter('appletStock')
          that.getParameter('myPromotion')
          that.getParameter('appletEmailReg')
          that.getParameter('appPhoneReg')
          that.getParameter('appVisitor')
          that.getParameter('changePhone')
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    onChange(e, record) {
      if (e.target.checked) {
        record.state = 1
      } else {
        record.state = 2
      }
      postAction(this.url.edit, record).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.loadData(1)
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    handleChange(value, id, column) {
      const newData = [...this.dataSource]
      const target = newData.filter((item) => id === item.id)[0]
      if (target) {
        target[column] = value
        this.dataSource = newData
      }
    },
    edit(id) {
      let that = this
      const newData = [...that.dataSource]
      const target = newData.filter((item) => id === item.id)[0]
      that.editingKey = id
      if (target) {
        target.editable = true
        that.dataSource = newData
      }
    },
    fedit(id) {
      let that = this
      const newData = [...that.dataSource]
      const target = newData.filter((item) => id === item.id)[0]
      that.feditingKey = id
      if (target) {
        target.feditable = true
        that.dataSource = newData
      }
    },
    save2(id) {
      let that = this
      const newData = [...that.dataSource]
      const target = newData.filter((item) => id === item.id)[0]
      if (target) {
        delete target.editable
        delete target.feditable
        putAction(that.url.edit, target).then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData(1)
          } else {
            that.$message.warning(res.message)
          }
        })
      }
      that.editingKey = ''
      that.feditingKey = ''
    },
    editSignin(item) {
      this.$set(item, 'disabled', false)
    },
    saveSignin(item, ind) {
      let i = 0
      if (!item.day || !item.couponId) {
        this.$message.warning(this.$t('请设置连续签到规则'))
        return
      }
      this.signinList.forEach((col) => {
        if (col.day != item.day) {
          i++
        } else {
          i--
        }
      })
      if (i == this.signinList.length - 2) {
        this.$set(this.signinList[ind], 'disabled', true)
      } else {
        this.$message.warning(this.$t('已存在重复的签到规则'))
      }
    },
    addSignin() {
      let obj = {}
      obj.day = ''
      obj.couponId = ''
      obj.disabled = false
      this.signinList.push(obj)
    },
    delSignin(i) {
      this.signinList.splice(i, 1)
      if (this.signinList.length == 0) {
        let obj = {}
        obj.day = ''
        obj.couponId = ''
        obj.disabled = false
        this.signinList.push(obj)
      }
    },
    getCoupons(info) {
      let that = this,
        query = {}
      if (info) {
        query.goodsInfo = info
      }
      query.form = '9'
      query.state = 'Y'
      query.notSystem = 1
      query.column = 'sort'
      query.order = 'asc'
      getAction('/goods/bisGoodsInfor/list', query).then((res) => {
        that.coupons = res.result.records
      })
    },
    getSignins() {
      let that = this
      getAction('/sign/bisSign/list').then((res) => {
        if (res.success) {
          if (res.result.records.length > 0) {
            let dtl = res.result.records[0]
            dtl.states = dtl.state ? true : false
            that.signinObj = Object.assign({}, dtl)
            that.getCouponShow()
            that.getSignSeriesList()
          } else {
            that.getCoupons()
            that.$set(that.signinObj, 'states', false)
            that.signinList = [
              {
                couponId: '',
                day: '',
                disabled: false,
              },
            ]
          }
        }
      })
    },
    getSignSeriesList() {
      let that = this
      getAction('/sign/bisSign/queryBisSignSeriesByMainId', { id: that.signinObj.id }).then((res) => {
        if (res.success) {
          if (res.result.length > 0) {
            that.signinList = res.result.map((sn) => {
              let dtl1 = Object.assign({}, sn, { disabled: true })
              return dtl1
            })
          } else {
            that.signinList = [
              {
                couponId: '',
                day: '',
                disabled: false,
              },
            ]
          }
        }
      })
    },
    saveSigninRule() {
      let that = this,
        httpurl = '',
        method = '',
        querydata = {}
      if (that.signinObj.id) {
        httpurl = '/sign/bisSign/edit'
        method = 'put'
      } else {
        httpurl = '/sign/bisSign/add'
        method = 'post'
      }
      if (that.signinObj.states && !that.signinObj.couponId) {
        that.$message.error(that.$t('请设置日常签到奖励'))
        return
      }
      let arr = that.signinList.filter((sn) => {
        return sn.disabled
      })
      querydata = Object.assign({}, that.signinObj, {
        state: that.signinObj.states ? 1 : 0,
        bisSignSeriesList: arr,
      })
      httpAction(httpurl, querydata, method).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.getSignins()
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    getCouponShow() {
      let that = this,
        query = {}
      query.form = '9'
      query.notSystem = 1
      query.column = 'sort'
      query.order = 'asc'
      query.pageSize = 100
      getAction('/goods/bisGoodsInfor/list', query).then((res) => {
        that.coupons = res.result.records
      })
    },
    getWallets() {
      axios
        .all([
          this.queryByName('appletHomeWalletOne'),
          this.queryByName('appletHomeWalletTwo'),
          this.queryByName('appletHomeWalletThree'),
        ])
        .then(
          axios.spread((r1, r2, r3) => {
            if (r1.success) {
              this.appletHomeWalletOne.id = r1.result.id
              this.appletHomeWalletOne.svalue = r1.result.svalue
            } else {
              this.appletHomeWalletOne.svalue = '1'
            }
            if (r2.success) {
              this.appletHomeWalletTwo.id = r2.result.id
              this.appletHomeWalletTwo.svalue = r2.result.svalue
            } else {
              this.appletHomeWalletTwo.svalue = '2'
            }
            if (r3.success) {
              this.appletHomeWalletThree.id = r3.result.id
              this.appletHomeWalletThree.svalue = r3.result.svalue
            } else {
              this.appletHomeWalletThree.svalue = '7'
            }
          })
        )
    },
    changeWalletOne(e) {
      this.saveWallet('appletHomeWalletOne')
    },
    changeWalletTwo(e) {
      this.saveWallet('appletHomeWalletTwo')
    },
    changeWalletThree(e) {
      this.saveWallet('appletHomeWalletThree')
    },
    saveWallet(name) {
      let that = this,
        querydata = {}
      let url = '',
        method = ''
      if(name=='appletHomeWalletOne'&&(that.appletHomeWalletOne.svalue==that.appletHomeWalletTwo.svalue||that.appletHomeWalletOne.svalue==that.appletHomeWalletThree.svalue)){
        that.$message.warning(that.$t('一种钱包类型仅支持设置一次'))
        that.getWallets()
        return
      }
      if(name=='appletHomeWalletTwo'&&(that.appletHomeWalletTwo.svalue==that.appletHomeWalletOne.svalue||that.appletHomeWalletTwo.svalue==that.appletHomeWalletThree.svalue)){
        that.$message.warning(that.$t('一种钱包类型仅支持设置一次'))
        that.getWallets()
        return
      }
      if(name=='appletHomeWalletThree'&&(that.appletHomeWalletThree.svalue==that.appletHomeWalletOne.svalue||that.appletHomeWalletThree.svalue==that.appletHomeWalletTwo.svalue)){
        that.$message.warning(that.$t('一种钱包类型仅支持设置一次'))
        that.getWallets()
        return
      }
      if (that[name].id) {
        url = '/bis/bisSysParameter/edit'
        method = 'put'
      } else {
        url = '/bis/bisSysParameter/add'
        method = 'post'
      }
      querydata = Object.assign({}, that[name])
      httpAction(url, querydata, method).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
        } else {
          that.getWallets()
        }
      })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
<style>
.table-padlr0 .ant-table.ant-table-small > .ant-table-content > .ant-table-body {
  margin: 0;
}
.table-padlr0 .ant-table-small > .ant-table-content > .ant-table-body > table > .ant-table-thead > tr > th {
  background-color: #fafafa;
}
</style>